package main
import (
	"fmt"
	"bufio"
	"os"
	"io"
)

func main(){
	filePath :="E:\\ProgramData\\GoWorkSpace\\src\\go_code\\project03/day1/abc.txt"
	file ,err := os.OpenFile(filePath,os.O_RDWR|os.O_APPEND,0666)

	if err!=nil{
		fmt.Printf("open file err = %v",err)
		return
	}

	defer file.Close()
	reader :=bufio.NewReader(file)
	for{
		str,err := reader.ReadString('\n')
		if err == io.EOF{
			break
		}

		fmt.Print(str)
	}

	
	str := "hello golang\r\n"
	writer :=bufio.NewWriter(file)
	writer.WriteString(str)
	writer.Flush()

}